import axios from '@/utils/request'
// import store from '@/store'
/**
 * 用户登录
 * @param {Number} mobile 手机号
 * @param {Number} code 验证码
 * @returns
 */
export function userLogin(mobile, code) {
  return axios({
    method: 'POST',
    url: '/v1_0/authorizations',
    // POST方式，数据写在data中
    data: {
      mobile,
      code
    }
  })
}

// !axios在拦截器里面统一配置token
export const getUserInfo = () => {
  // const token = store.state.user.token.token
  return axios({
    method: 'GET',
    url: '/v1_0/user/profile'
    // headers: {
    //   Authorization: 'Bearer ' + token
    // }
  })
}

/**
 * 修改用户资料
 * @param {*} data 需要修改的数据对象
 * @returns
 */
export const editUserInfo = (data) =>
  axios({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
/**
 * 修改用户头像
 * @param {*} fd
 * @returns
 */
export const editAvatar = (fd) =>
  axios({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fd
  })
